#include<bits/stdc++.h>
using namespace std;
struct node{
    int a;
    bool color_blue;
}a[200001];
int n,ans;
int num()
{
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        bool f=false;
        int z;
        for(int j=i-1;j>=1;j--)
        {
            if(a[i].color_blue==a[j].color_blue)
            {
                if(a[i].a==a[j].a)
                {
                    ans+=a[i].a;
                }
                break;
            }
        }
    }
    return ans;
}
void dfs(int pre)
{
    if(pre>n)
    {
        ans=max(ans,num());
        return ;
    }
    a[pre].color_blue=true;
    dfs(pre+1);
    a[pre].color_blue=false;
    dfs(pre+1);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    cin>>T;
    for(int l=1;l<=T;l++)
    {
        cin>>n;
        ans=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i].a;
        }
        dfs(1);
        cout<<ans<<'\n';
    }
    cout<<'\n';
    return 0;
}
